package top.kangshuai.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import top.kangshuai.model.UserModel;
import top.kangshuai.service.UserService;
import top.kangshuai.utils.JsonMessage;

/**
 * 用户信息控制器
 * 
 * @author ks187
 *
 */
@RestController
@RequestMapping("/user")
public class UserController {
  @Autowired
  private UserService userService;

  @RequestMapping("/login")
  public JsonMessage login(UserModel model) throws Exception {
    //http://127.0.0.1:20001/user/login?token=94591dc5-89a7-4921-b291-09a0e1cf1ff9&user.username=test&user.password=test-pwd
    //{"user.username":"test","user.password":"test-pwd"}
    return userService.login(model);
  }
  @RequestMapping("/logout")
  public JsonMessage logout(UserModel model) throws Exception{
    // /user/logout
    return userService.logout(model);
  }
  @RequestMapping("/getUserInfo")
public JsonMessage getUserInfo(UserModel model)throws Exception{
  //http://127.0.0.1:20001/user/getUserInfo?token=dc915671-2b41-4880-8098-679cc3b04bef
  ///user/getUserInfo {}
    return userService.getUserInfo(model);
}
}
